using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper {
	public class BillMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public BillMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
            _cfg.CreateMap<Bill, bill_dto>()
                .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
                .ForMember(dest => dest.merchant_id, src => src.MapFrom(c => c.MerchantId))
                .ForMember(dest => dest.balance, src => src.MapFrom(c => c.Balance))
                .ForMember(dest => dest.unconfirmed, src => src.MapFrom(c => c.Unconfirmed))
                .ForMember(dest => dest.deposited, src => src.MapFrom(c => c.Deposited))
                .ForMember(dest => dest.depositeding, src => src.MapFrom(c => c.Depositeding))
                .ForMember(dest => dest.deposit, src => src.MapFrom(c => c.Deposit))
                .ForMember(dest => dest.goods_unconfirmed, src => src.MapFrom(c => c.GoodsUnconfirmed))
                .ForMember(dest => dest.goods_deposit, src => src.MapFrom(c => c.GoodsDeposit))
                .ForMember(dest => dest.goods_depositing, src => src.MapFrom(c => c.GoodsDepositing))
                .ForMember(dest => dest.goods_deposited, src => src.MapFrom(c => c.GoodsDeposited))
                .ForMember(dest => dest.freeze, src => src.MapFrom(c => c.Freeze))
                .ForMember(dest => dest.security, src => src.MapFrom(c => c.Security))
                .ForMember(dest => dest.out_profit, src => src.MapFrom(c => c.OutProfit))
                .ForMember(dest => dest.other_amt, src => src.MapFrom(c => c.OtherAmt));
               


			_cfg.CreateMap<PlatBill, plat_bill_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.balance, src => src.MapFrom(c => c.Balance))
				.ForMember(dest => dest.pay_channel, src => src.MapFrom(c => c.PayChannel))
				.ForMember(dest => dest.unconfirmed, src => src.MapFrom(c => c.Unconfirmed))
				.ForMember(dest => dest.deposited, src => src.MapFrom(c => c.Deposited))
				.ForMember(dest => dest.depositeding, src => src.MapFrom(c => c.Depositeding))
				.ForMember(dest => dest.channel_balance, src => src.MapFrom(c => c.ChannelBalance));
			_cfg.CreateMap<bill_model, BillQuery>();

            _cfg.CreateMap<Bill, bill_ex>()
            .ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
            .ForMember(dest => dest.merchant_id, src => src.MapFrom(c => c.MerchantId))
            .ForMember(dest => dest.balance, src => src.MapFrom(c => c.Balance))
            .ForMember(dest => dest.unconfirmed, src => src.MapFrom(c => c.Unconfirmed))
            .ForMember(dest => dest.deposited, src => src.MapFrom(c => c.Deposited))
            .ForMember(dest => dest.depositeding, src => src.MapFrom(c => c.Depositeding))
            .ForMember(dest => dest.deposit, src => src.MapFrom(c => c.Deposit))
            .ForMember(dest => dest.freeze, src => src.MapFrom(c => c.Freeze))
            .ForMember(dest => dest.security, src => src.MapFrom(c => c.Security))
            .ForMember(dest => dest.out_profit, src => src.MapFrom(c => c.OutProfit))
            .ForMember(dest => dest.other_amt, src => src.MapFrom(c => c.OtherAmt))
            .ForMember(dest => dest.mobile, src => src.MapFrom(c => c.Merchant.Mobile))
            .ForMember(dest => dest.bill_id, src => src.MapFrom(c => c.Id));
        }
	}
}
